#include "motor.h"
#include "gpio/_gpio.h"

void motor_start(motor_t* motor)
{
    gpio_write_pin(motor->dir1, 1);
    gpio_write_pin(motor->dir2, 0);
}

void motor_stop(motor_t* motor)
{
    gpio_write_pin(motor->dir1, 0);
    gpio_write_pin(motor->dir2, 0);
}

void motor_set_speed(motor_t* motor, float duty)
{
    DL_TimerG_setCaptureCompareValue(motor->timer_inst, duty * MOTOR_TIMER_MAX_COUNT, motor->cc_index);
}
